<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
         
        <div v-ellipsis>
            dfsdfffffffffffffffffffffffffffffffffffffaaaaaaaaaa
        </div>
    </div>
</body>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script  >
    // 全局指令
   
    Vue.directive('ellipsis',{
        inserted:function(el,binding){
            el.style.width = 100 + 'px'
            el.style.whiteSpace = 'nowrap'
            el.style.overflow = 'hidden'
            el.style.textOverflow = 'ellipsis'
        }
    })
  
    var vue = new Vue({
        el:'#app',
        data:{
           fruits:['apple','pear','banana','orange'],
           phone:''
        },
        directives:{
         
           ellipsis:{
               inserted:function(el,binding){
                   console.log('el',el)
                   console.log('binding',binding)
                    el.style.width = 100 + 'px'
                el.style.whiteSpace = 'nowrap'
                el.style.overflow = 'hidden'
                el.style.textOverflow = 'ellipsis'
               }
           }
        }
    })
</script>
</html>